package parser.graph;

import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlRootElement;

import smarties.SmartInfoManager;
import smarties.SmartNode;
import smarties.info.SmartDateInfo;
import smarties.info.SmartDoubleInfo;
import smarties.info.SmartIntegerInfo;
import smarties.info.SmartStringInfo;
import smarties.style.CircleStyle;
import smarties.style.EmptyRingStyle;
import smarties.style.SmartStyle;

/**
 * Permet le chargement d'un noeud du graphe.
 * 
 * @author buthane
 */
@XmlRootElement(name = "node")
public class SmartNodeParser
{
	private static int		instanceCount	= 0;

	private final SmartNode	node			= new SmartNode(null, null);

	public static int getInstanceCount()
	{
		return SmartNodeParser.instanceCount;
	}

	@XmlElement(name = "id")
	@XmlID
	public void setId(String id)
	{
		this.node.setID(id);
	}

	public String getId()
	{
		return this.node.getID();
	}

	@XmlElement(name = "label")
	public void setLabel(String label)
	{
		this.node.setLabel(label);
		SmartInfoManager.getInstance().addTextInfo(label, this.node);
	}

	public String getLabel()
	{
		return this.node.getLabel();
	}

	@XmlElement(name = "type")
	public void setType(String type)
	{
		this.node.setType(type);
	}

	public String getType()
	{
		return this.node.getType();
	}

	@XmlElement(name = "info")
	public void setInfoUsed(String info)
	{
		this.node.setInfoUsed(info);
	}

	public String getInfoUsed()
	{
		return this.node.getInfoUsed();
	}

	@XmlElement(name = "string")
	public void setStringInfo(List<SmartStringInfo> infoList)
	{
		for (SmartStringInfo info : infoList)
		{
			this.node.addInfo(info);
			SmartInfoManager.getInstance().addStringInfo(info, this.node);
		}
	}

	public List<SmartStringInfo> getStringInfo()
	{
		return null;
	}

	@XmlElement(name = "integer")
	public void setIntegerInfo(List<SmartIntegerInfo> infoList)
	{
		for (SmartIntegerInfo info : infoList)
		{
			this.node.addInfo(info);
			SmartInfoManager.getInstance().addIntegerInfo(info, this.node);
		}
	}

	public List<SmartIntegerInfo> getIntegerInfo()
	{
		return null;
	}

	@XmlElement(name = "double")
	public void setDoubleInfo(List<SmartDoubleInfo> infoList)
	{
		for (SmartDoubleInfo info : infoList)
		{
			this.node.addInfo(info);
			SmartInfoManager.getInstance().addDoubleInfo(info, this.node);
		}
	}

	public List<SmartDoubleInfo> getDoubleInfo()
	{
		return null;
	}

	@XmlElement(name = "date")
	public void setDateInfo(List<SmartDateInfo> infoList)
	{
		for (SmartDateInfo info : infoList)
		{
			this.node.addInfo(info);
			SmartInfoManager.getInstance().addDateInfo(info, this.node);
		}
	}

	public List<SmartDateInfo> getDateInfo()
	{
		return null;
	}

	@XmlElement(name = "smartStyle")
	public void setSmartStyle(SmartStyle style)
	{
		this.node.setStyle(style);
	}

	public SmartStyle getSmartStyle()
	{
		return this.node.getStyle();
	}

	@XmlElement(name = "circleStyle")
	public void setCircleStyle(CircleStyle style)
	{
		this.setSmartStyle(style);
	}

	public CircleStyle getCircleStyle()
	{
		return (CircleStyle) this.getSmartStyle();
	}

	@XmlElement(name = "emptyRingStyle")
	public void setEmptyRingStyle(EmptyRingStyle style)
	{
		this.setSmartStyle(style);
	}

	public EmptyRingStyle getEmptyRingStyle()
	{
		return (EmptyRingStyle) this.getSmartStyle();
	}

	@XmlElement(name = "localityRadius")
	public void setLocalityRadius(int radius)
	{
		this.node.setLocalityRadius(radius);
	}

	public int getLocalityRadius()
	{
		return this.node.getLocalityRadius();
	}

	public SmartNode getSmartNode()
	{
		return this.node;
	}

	public SmartNodeParser()
	{
		SmartNodeParser.instanceCount++;
	}
}
